import { addFolder } from '@/services/files'
import { PlusOutlined } from '@ant-design/icons'
import {
  ModalForm,
  ProForm,
  ProFormDateRangePicker,
  ProFormSelect,
  ProFormText,
} from '@ant-design/pro-components'
import { Button, Form, message } from 'antd'

//传title、
export default function CreateForm(props: any) {
  const [form] = Form.useForm<{ name: string; company: string }>()
  return (
    <ModalForm<{
      name: string
    }>
      width="20vw"
      title="新建文件夹"
      trigger={
        <Button type="primary">
          <PlusOutlined />
          新建文件夹
        </Button>
      }
      form={form}
      autoFocusFirstInput
      modalProps={{
        destroyOnClose: true,
        onCancel: () => console.log('run'),
      }}
      submitTimeout={500}
      onFinish={async (values) => {
        const result = await addFolder({
          parentId: props?.parentId,
          name: values?.name,
        })
        message.success('提交成功')
        props?.actionRef.current.reload()
        return true
      }}>
      <ProFormText
        width="md"
        name="name"
        label="文件夹名称"
        tooltip="最长为 24 位"
        placeholder="请输入文件夹名称"
      />
    </ModalForm>
  )
}
